# 2024/1/30 21:59 HFL
import re

import requests
import unittest
from ddt import ddt, file_data

from common.MD5 import Bmd5


@ddt
class Apizbox(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.s = requests.session()

    @classmethod
    def tearDownClass(cls):
        pass

    @file_data('../data/chandao.yaml')
    def test_apizbox(self,data,exp):
        url = 'http://192.168.12.7:8080/zentao/user-login.html'
        res = self.s.get(url)
        verify = re.findall("name='verifyRand' id='verifyRand' value='(.*?)'", res.text)
        print(verify[0])
        password = 'admin123.'
        fits = md5(password)
        hyax = md5(fits + verify[0])
        data['password'] = hyax
        data['verifyRand'] = verify[0]
        self.s.post(url=url,data=data)

        res3 = self.s.post('http://192.168.12.7:8080/zentao/my/')
        self.assertIn(exp['ass'],res3.text)



if __name__ == '__main__':
    unittest.main()
